
import * as THREE from 'three'
import { map, AMap, scene, camera, renderer, customLayer, customCoords } from './AMapScene'
import { numArr2v3 } from '../utils'

window.onload = () => {
    let arr = []
    map.on('click', (e: any) => {
        const lnglat: [number, number] = [e.lnglat.lng, e.lnglat.lat]
        console.log('lnglat', lnglat);

        console.log(`第${arr.length+1}个点${lnglat[0]},${lnglat[1]}`)
        arr.push(lnglat)
        console.log(arr)
        console.log(JSON.stringify(arr))
        // var position = customCoords.lngLatsToCoords([
        //     lnglat
        // ])[0];

        // const cube = creatCube()
        // cube.position.copy(numArr2v3(lnglat))
        // cube.position.setX(position[0])
        // cube.position.setY(position[1])
        // scene.add(cube)
        
        // console.log(camera.position);
        


    })
}

const creatCube = () => {
    const geometry = new THREE.BoxGeometry(10, 10, 10);
    const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
    const cube = new THREE.Mesh(geometry, material);
    return cube
}